<meta charset="UTF-8">
<!--
To change this license header, choose License Headers in Project Properties.
To change this template file, choose Tools | Templates
and open the template in the editor.
-->
        <script type="text/javascript">
            function check_input(form){
                if(form.username.value==""){
                    alert("请输入用户名!");
                    form.username.select();
                    return(false);
                }
                if(form.password.value==""){
                    alert("请输入用户密码!");
                    form.password.select();
                    return(false);
                }
                if(form.yanzhengma.value==""){
                    alert("请输入验证码!");
                    form.yanzhengma.select();
                    return(false);
                }
                return(true);
            }
            function check_search(form){
                if(form.bookname.value==""){
                    alert("请输入图书名!");
                    form.bookname.select();
                    return(false);
                }
                return(true);
            }
            function openfindpwd(){
                window.open("openfindpwd.php","newframe","left=200,top=200,width=200,height=100,menubar=no,toolbar=no,location=no,scrollbars=no,location=no");
            }
        </script>
        <?php
        /**
         * @todo 用户登录之后取消登录界面，并显示欢迎界面
         * @todo 在用户已登陆情况下点击注册后的逻辑优化
         * @todo 在用户已登陆情况下点击找回密码后的逻辑优化
         */
        // put your code here
        include ("conn/conn.php");
        $conn = prepare();
        ?>
        <table width="209" height="300" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="153"><table width="209" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="33" colspan="3" align="center">用户登录</td>
            </tr>
            <tr>
              <td width="15">&nbsp;</td>
              <td width="177"><table width="180" height="10" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" height="100" border="0" align="center" cellpadding="0" cellspacing="1">
                      <tr>
                        <td><table width="180" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                              <td><table width="300" border="0" cellpadding="0" cellspacing="1">
                                  <form name="form" method="post" action="check_user_login.php" onSubmit="return check_input(this)">
                                    <tr>
                                      <td height="20"><div align="center">用户名：</div></td>
                                      <td height="20" colspan="2"><div align="left">
                                          <input type="text" name="username" size="20">
                                      </div></td>
                                    </tr>
                                    <tr>
                                      <td height="20"><div align="center">密码：</div></td>
                                      <td colspan="2"><div align="left">
                                              <input type="password" name="password" size="20" maxlength="18">
                                      </div></td>
                                    </tr>
                                    <tr>
                                      <td height="20"><div align="center">验证码：</div></td>
                                      <td colspan="2" height="20"><div align="left">
                                              <input type="text" name="yanzhengma" size="10" maxlength="4">&nbsp;
                                              <?php
                                              /**
                                               * @remark 长见识了，原来验证码也可以这样生成
                                               * @todo 点击验证码刷新
                                               * @todo 验证码输入错误后再次刷新验证码
                                               */
                                              $num=intval(mt_rand(1000,9999));
                                              for($i=0;$i<4;$i++){
                                                  echo "<img src=image/code/".substr(strval($num),$i,1).".gif align='center'>";
                                              }
                                              ?>
                                          </div>
                                      </td>
                                    </tr>
                                    <tr>
                                      <td height="20" colspan="3"><div align="center">
                                          <input type="hidden" value="<?php echo $num;?>" name="num">
                                          <input name="submit" type="submit" value="提 交">
<a href="register.php">注册</a>&nbsp;<a href="findmemberspwd.php">找回密码</a>&nbsp;</div></td>
                                    </tr>
                                  </form>
                              </table></td>
                            </tr>
                        </table></td>
                      </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
        </table>
        <table width="209" border="0" cellspacing="0" cellpadding="0">
        <tr>
          <td height="153"><table width="209" border="0" cellspacing="0" cellpadding="0">
            <tr>
              <td height="33" colspan="3" align="center">图书搜索</td>
            </tr>
            <tr>
              <td width="15">&nbsp;</td>
              <td width="177"><table width="180" height="10" border="0" align="center" cellpadding="0" cellspacing="0">
                <tr>
                  <td valign="top"><table width="100%" height="100" border="0" align="center" cellpadding="0" cellspacing="1">
                      <tr>
                        <td><table width="180" height="100" border="0" align="center" cellpadding="0" cellspacing="0">
                            <tr>
                              <td><table width="300" border="0" cellpadding="1" cellspacing="0">
                                  <form name="form" method="post" action="findbook.php" onSubmit="return check_search(this)">
                                    <tr>
                                      <td height="20"><div align="center">书名：</div></td>
                                      <td height="20" colspan="2"><div align="left">
                                          <input type="text" name="bookname" size="20">
                                      </div></td>
                                    </tr>
                                    <tr>
                                      <td height="20" colspan="3">
                                          <div align="center">
                                            <input name="search" type="submit" value="搜 索">
                                            <input name="advanced_search" type="button" onClick="javascript:window.location='advanecdfind.php';" value="高级搜索">
                                          </div></td>
                                    </tr>
                                  </form>
                              </table></td>
                            </tr>
                        </table></td>
                      </tr>
                  </table></td>
                </tr>
              </table></td>
            </tr>
          </table></td>
        </tr>
        </table>
